package com.lifang.imsoa.util;

import java.util.List;
import java.util.Random;

import org.apache.commons.collections4.CollectionUtils;

public class RandomUtils {
	private static Random random = new Random();

	/**
	 * 获得随机整数，如参数为10，则随机范围为[1,10]
	 */
	public static int getRandom(int scale){
		return random.nextInt(scale)+1;
	}

	public static <E> E getRandomNode(List<E> list){
		if(CollectionUtils.isEmpty(list)){
			return null;
		}else{
			return list.get(getRandom(list.size())-1);
		}
	}
}
